<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>table模块快速使用</title>
    <link rel="stylesheet" href="kit_admin/plugins/layui/css/layui.css" media="all">
</head>

<body>

<div class="layui-btn-group demoTable">
  <button class="layui-btn" data-type="add">新增用户</button>
  <button class="layui-btn" data-type="edit">编辑用户</button>
  <a href="userController.do?export" class="layui-btn" target="_blank">简单导出</a>
</div>
    <table class="layui-table" lay-data="{height:315, url:'userController.do?dataGrid', page:true, id:'userList',height: 'full-25'}" lay-filter="role" id="test">
        <thead>
            <tr>
            		<th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                <th lay-data="{field:'id', width:200, sort: true}">id</th>
                <th lay-data="{field:'staffNo', width:200, sort: true}">员工编号</th>
                <th lay-data="{field:'name', width:200, sort: true}">用户名</th>
                <!-- <th lay-data="{field:'username', width:80}">用户名</th>
                <th lay-data="{field:'sex', width:80, sort: true}">性别</th>
                <th lay-data="{field:'city', width:80}">城市</th>
                <th lay-data="{field:'sign', width:177}">签名</th>
                <th lay-data="{field:'experience', width:80, sort: true}">积分</th>
                <th lay-data="{field:'score', width:80, sort: true}">评分</th>
                <th lay-data="{field:'classify', width:80}">职业</th>
                <th lay-data="{field:'wealth', width:135, sort: true}">财富</th> -->
            </tr>
        </thead>
    </table>

    <script src="kit_admin/plugins/layui/layui.js"></script>
    <script>
        layui.use('table', function() {
            var table = layui.table;
       
        
        var $ = layui.$, active = {
        	    add: function(){ //添加数据
        	      /* var checkStatus = table.checkStatus('idTest')
        	      ,data = checkStatus.data;
        	      layer.alert(JSON.stringify(data)); */
        	    		layer.open({
        	    		  type: 2,
        	    		  title: false,
        	    		  area: ['630px', '360px'],
        	    		  btn: ['确定', '取消'], //只是为了演示
        	    		  shade: 0.8,
        	    		  closeBtn: 1,
        	    		  shadeClose: true,
        	    		  content: 'userController.do?goAdd',
        	    		  yes: function(index){
        	    			  //var cc=layer.find("#hohdx_1").text();
        	    			  window["layui-layer-iframe" + index].kh.commit();
        	    			  
        	    			  table.reload('userList', {
        	    			        page: {
        	    			          curr: 1 //重新从第 1 页开始
        	    			        }
        	    			        ,where: {
        	    			          key: {
        	    			          }
        	    			        }
        	    			      });
        	    		  }
        	    		});
        	    }
        	    ,edit: function(){ 
        	      var checkStatus = table.checkStatus('userList')
        	      ,data = checkStatus.data;
        	      layer.msg('选中了：'+ data.length + ' 个');
        	    }
        	  };
        	  
        	  $('.demoTable .layui-btn').on('click', function(){
        	    var type = $(this).data('type');
        	    active[type] ? active[type].call(this) : '';
        	  });
        });
    </script>
</body>

</html>